package com.zh.note.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 全局异常处理器
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler({ArithmeticException.class, NullPointerException.class})
    public String handlerArithmeticException(Exception e) {

        log.error("异常是:{}", e);
        return "error"; // 返回视图地址
    }

    @ExceptionHandler(RedisLimitException.class)
    public int handlerRedisLimitException() {
        return super.hashCode();
    }
}
